import { TPetUpgrage } from "../../../Message/Db/Tables/TPetUpgrage";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
import { EPetUpgradeType } from "../../../Message/Game/EPetUpgradeType";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
type int = number;
//class PetUpgradeConfig
    
    export  class PetUpgradeConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            this._gradeMap = new Map<any, any> /* flash.utils.Dictionary */();
            this._growList = [];
            this._spiritList = [];
            if (PetUpgradeConfig._instance != null) 
            {
                throw new Error(" PetUpgradeConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TPetUpgrage();
                loc1.type = loc2.type;
                loc1.grade = loc2.grade;
                loc1.needNum = loc2.needNum;
                loc1.color = loc2.color;
                loc1.addNum = loc2.addNum;
                loc1.title = StringHelper.getString(loc2.title);
                this._map[loc1.type + "_" + loc1.needNum] = loc1;
                this._gradeMap[loc1.type + "_" + loc1.grade] = loc1;
                if (loc1.type == EPetUpgradeType._EPetUpgradeTypeGrowth) 
                {
                    this._growList.push(loc1);
                    continue;
                }
                this._spiritList.push(loc1);
            }
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_pet_upgrage.json");
            this.write(loc1);
            return;
        }

        public getInfoByType(arg1: int, arg2: int): TPetUpgrage
        {
            return this._map[arg1 + "_" + arg2];
        }

        public getInfoByGrade(arg1: int, arg2: int): TPetUpgrage
        {
            return this._gradeMap[arg1 + "_" + arg2];
        }

        public PetUpgradeConfig.get growList(): Array<any>
        {
            return this._growList;
        }

        public PetUpgradeConfig.get spiritList(): Array<any>
        {
            return this._spiritList;
        }

        public set spiritList(arg1: Array<any>)
        {
            this._spiritList = arg1;
            return;
        }

        public static get instance(): PetUpgradeConfig
        {
            if (PetUpgradeConfig._instance == null) 
            {
                PetUpgradeConfig._instance = new PetUpgradeConfig();
            }
            return PetUpgradeConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_gradeMap: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_growList: Array<any>;

        /* internal */ /* var */_spiritList: Array<any>;

        /* internal */ static /* var */_instance: PetUpgradeConfig;
    }
